@include('admin.header')
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		
		<form method="post" class="form-horizontal js-form-info">
			<div class="row-fluid">
				<table class="table table-bordered">
					<tr>
						<th>员工名称</th>
						<td>
							<input type="text" style="width:400px;" name="worker_name"  value="{{$data->worker_name or '' }}" placeholder="员工名称"/>
						</td>
					</tr>

					<tr>
						<th>描述</th>
						<td>
							<input type="text" style="width:400px;" name="worker_desc"  value="{{$data->worker_desc or '' }}" placeholder="描述"/>
						</td>
					</tr>

					<tr>
						<th>手机</th>
						<td>
							<input type="text" style="width:400px;" name="nodecode"  value="{{$data->nodecode or '' }}" placeholder="手机"/>
						</td>
					</tr>

					<tr>
						<th>分润百分比</th>
						<td>
							<input type="text" style="width:400px;" name="profit_percent"  value="{{$data->profit_percent or '' }}" placeholder="分润百分比"/>
						</td>
					</tr>

					<tr>
						<th>状态</th>
						<td>
							<select id="status"  name="status">
								<option value="1" @if($data->id >0) @if($data->status == 1) selected="selected" @endif @endif>启用</option>
								<option value="2" @if($data->id >0) @if($data->status == 2) selected="selected" @endif @endif>禁用</option>
							</select>
						</td>
					</tr>
				</table>
			</div>
			<div class="form-actions">
				<input type="hidden" name="id" value="{{$data->id or 0}}"/>
				<input type="hidden" name="_token"  value="{{csrf_token()}}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{{asset('vshops_worker')}}">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="/static/js/common.js"></script>
	<script type="text/javascript" src="/static/js/validate/validate.js"></script>
	<script type="text/javascript" src="/static/js/layer/layer.js"></script>
	<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>
	<script type="text/javascript">
		$(function() {
			$(".js-form-info").validate({
				rules: {
					worker_name: {
						required: true
					},
					worker_desc: {
						required: true
					},
					nodecode: {
						required: true
					},
					profit_percent: {
						required: true
					}
				},
				messages: {
					worker_name: {
						required: "请输入员工名称"
					},
					worker_desc: {
						required: "请输入员工描述"
					},
					nodecode: {
						required: "请输入手机"
					},
					profit_percent: {
						required: "请输入分润百分比"
					}
				},
				submitHandler: function () {
					$.post("/vshops_worker/save", $('.js-form-info').serialize(), function (msg) {
						if (msg.status == 1) {
							layer.confirm(msg.info, {
								btn: ['确定']
							}, function(){
								window.location.reload();
							});
						} else {
							showMsg(msg.info);
						}
					}, 'json');
					return false;
				}
			});
		});

		/**
		 * layer提示
		 */
		function showMsg(msg){
			layer.alert(msg, {
				title: '提示',
				icon: 2,
			});
		}
	</script>
</body>
</html>